package com.einmeer.controller;


import com.einmeer.entity.SysFile;
import com.einmeer.service.SysFileService;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.awt.*;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 系统文件表 前端控制器
 * </p>
 *
 * @author einmeer
 * @since 2024-03-18
 */
@RestController
@RequestMapping("/sysFile")
public class SysFileController {
    @Resource
    SysFileService sysFileService;
    @PostMapping("/{bucket}/upload")
    String upload(MultipartFile file, @PathVariable("bucket") String bucket) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        System.out.println("图片"+file.getOriginalFilename());
        System.out.println(bucket);
        return sysFileService.upload(file,bucket);
    }
}
